package com.biwano.swapmyjob.objects;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Transient;

@Entity
public class JobType {

	private int id;
	
	private String en;
	
	public JobType() {}

	public JobType(String en_US) {
		super();
		this.en = en_US;
	}

	@Id @GeneratedValue( strategy = GenerationType.IDENTITY )
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getEn() {
		return en;
	}

	public void setEn(String en_US) {
		this.en = en_US;
	}
	@Transient 
	public String localisedJobType(String lang)
	{
		String ret="null";
		try {
			String methname = "get" + 
			Character.toUpperCase(lang.charAt(0)) +
					lang.substring(1);
			Method method = this.getClass().getMethod(methname);
			ret = (String) method.invoke(this, new Object[]{});
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			ret = getEn();
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalArgumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return ret;
		
	}
	
}
